home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
prodpack.zip
/
DB4PPSRC.EXE
/
_CAT4DBF.PRG
next >
Wrap
Text File
|
1993-05-04
|
4KB
|
126 lines
PROCEDURE _Cat4Dbf
PARAMETERS pc_fname, pc_result, pl_isqbe, pl_catopnd
*--------------------------------------------------------------------
* NAME
* _Cat4Dbf - determine name of DBF or QBE associated with a form
*
* DESCRIPTION
* The _Cat4Dbf procedure will determine the DBF or view that is
* related to the <pc_fname> file. If _Cat4Dbf found a match based
* on the catalog CODE field, it will put the DBF or view name
* in <pc_result>. If the match was a view, it will set <pl_isqbe>
* to a true value, otherwise it will be a false value.
*
* If the catalog file is opened and you want to keep it open,
* set the value of <pl_catopnd> to a true value.
*
* SYNOPSIS
* DO _Cat4Dbf WITH <pc_fname>, <pc_result>, <pl_isqbe>, <pl_catopnd>
*
* EXAMPLE
* *-- Find the DBF for GOODS.SCR
* lc_dbf = "" && Set up the result DBF name
* ll_qbe = .F. && Set up the was it a QBE flag
* DO _Cat4Dbf WITH "GOODS.SCR", lc_dbf, ll_qbe, .F.
* IF .NOT. ISBLANK( lc_dbf ) && If a DBF was found
* ... && Put your DBF code here
* ENDIF
*
* PARAMETERS
* pc_fname = name of the SCR file to find DBF or QBE with
* pc_result = returns name of matching DBF or QBE file
* pl_isqbe = returns .T. if SCR matches QBE file
* pl_catopnd = .T. if catalog is already opened
*
* DEPENDENCIES
* Creates the following public memory variables:
* FXC_CTAG = Value of the catalog TAG field for the given SCR file.
* Will be "PRG" for a Master-Detail form, blank for others.
* This varaible is used by _FXExit to determine the
* generate style without having to scan the SCB file.
*
* Calls: _CatOpen - Open a dBASE catalog file
* _CatClose - Close a dBASE catalog file
* _CatCode - Determine the catalog code for a specified file
*
* Called by: _FXUseIt - Use the correct DBF or View based on extensions
*
* VARIABLES
* lc_alias = Name of ALIAS() for current WA
* ll_opened = If the catalog file was opened, then it's set to .T.,
* else it will be .F.
* ll_catalog = State of CATALOG, .T. if on, .F. if off
* ln_code = Return CODE field for catalog file. If 0, then the
* file doesn't have a related DBF or QBE file.
*--------------------------------------------------------------------
PRIVATE lc_alias, ll_opened, ll_catalog, ln_code
pc_result = "" && Result of the matching DBF/QBE
lc_alias = ALIAS() && Save the alias for any open dbf
ll_opened = .F. && Let others know catalog not open
ll_catalog = SET( "CATALOG" ) = "ON"
SET CATALOG OFF && Force the catalog off
IF .NOT. pl_catopnd && If the catalog is not open
DO _CatOpen WITH ll_opened && Try and open it
ELSE
ll_opened = .T. && Signal that the catalog is open
ENDIF
RELEASE FXC_ctag
PUBLIC FXC_ctag
FXC_ctag = ""
IF ll_opened && If the catalog is now open
SELECT FXCatalog
ln_code = -1 && Assume the worst
DO _CatCode WITH pc_fname, ln_code && Get the code for the file
IF ln_code > -1 && If the code exists
FXC_ctag = UPPER( tag )
*-- Now look for a matching DBF reference based on code
*-- Assume that the type is always lowercase. Vue files are
*-- not included.
LOCATE FOR ( LOWER( type ) $ "dbf,qbe" ) .AND. ;
code = ln_code
IF FOUND()
pc_result = TRIM(FXCatalog->path) && Store matching dbf/qbe to result
IF LOWER( FXCatalog->type ) = "qbe" && If it's a qbe file
pl_isqbe = .T. && Let the calling program know it
ENDIF
ENDIF
ENDIF
IF .NOT. pl_catopnd && If catalog wasn't open before
DO _CatClose && Close the catalog
ENDIF
ENDIF
IF .NOT. ISBLANK( lc_alias ) && And there was a file open already
SELECT ( lc_alias ) && Re-select the beginning work area
ENDIF
IF ll_catalog
SET CATALOG ON
ENDIF
RETURN
*-- EOP: _Cat4Dbf WITH pc_fname, pc_result, pl_isqbe, pl_catopnd